package com.czf.alibaba_seata_provider1.provier;

import com.alibaba.fastjson.JSON;
import com.czf.alibaba_api.busi.IBusiService;
import com.czf.alibaba_seata_provider1.entity.BusiEntity;
import io.seata.core.context.RootContext;
import io.seata.spring.annotation.GlobalTransactional;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.UUID;

/**
 * @author: create by czf
 * @version: v1.0
 * @description: com.czf.alibaba_seata_provider1.provier
 * @date: 2020-03-28 15:34
 **/
@Service
public class BusiProvider implements IBusiService {

    @Autowired
    com.czf.alibaba_seata_provider1.service.IBusiService bs;

    @Override
    public String getAllBusi() {
        String xid = RootContext.getXID();

        System.out.println("事务ID：" + xid);

        System.out.println("进来busi方法~~~````````");
        BusiEntity be = new BusiEntity();
        be.setId(UUID.randomUUID().toString().replace("-",""));
        be.setBusiName("busi猫头鹰");
        be.setCreateTime(new Date());

        return bs.save(be)?"yes":"no";
//        return JSON.toJSONString(bs.list());
    }

}
